<?php if (!defined('THINK_PATH')) exit();?><table class="table table-bordered" style="margin-top: 0px;">
    <thead>
    <tr>
        <th width="8%">拍卖单号</th>
        <th width="16%">车型</th>
        <th width="5%">所在地</th>
        <?php if($params["status"] == 1 OR $params["status"] == 2 OR $params["status"] == 3): ?><th width="8%">车主姓名</th>
                <th width="10%">车主电话</th>
            <?php elseif($params["status"] == 4): ?>
                <th width="6%">磋商成交价</th><?php endif; ?>
        <?php if($params["status"] == 4): ?><th width="6%">拍卖最高价</th>
            <?php else: ?>
            <th width="6%">第一名出价</th><?php endif; ?>

        <th width="6%">保留价</th>
        <?php if($params["status"] == 4): ?><th width="10%">渠道来源</th>
            <?php if($params["auth"] AND $params["status"] == 4): ?><th width="6%">操作客服</th><?php endif; ?>
            <th width="12%">磋商时间</th><?php endif; ?>
        <?php if($params["auth"] AND $params["status"] > 1 AND $params["status"] != 4): ?><th width="6%">操作客服</th><?php endif; ?>
        <?php if($params["status"] == 2): ?><th width="10%">下次跟踪时间</th><?php endif; ?>
        <th width="6%">操作</th>

    </tr>
    </thead>
    <tbody>
    <?php if(is_array($list)): $k = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($k % 2 );++$k;?><tr>
            <td class="mcenter"><?php echo ($vo["order_no"]); ?></td>
            <td><a href="/Car/report/car_id/<?php echo ($vo["car_id"]); ?>" target="_blank"><?php echo ($vo["model"]); ?></a></td>
            <td class="mcenter"><?php echo ($vo["location_area_name"]); ?></td>
            <?php if($params["status"] == 1): ?><td class="mcenter"><?php echo ($vo["seller_name"]); ?></td>
                <td class="mcenter"><?php echo ($vo["phone_has_star"]); ?></td>
                <?php elseif($params["status"] == 2 OR $params["status"] == 3): ?>
                <td class="mcenter"><?php echo ($vo["seller_name"]); ?></td>
                <td class="mcenter"><?php echo ($vo["phone"]); ?></td>
                <?php elseif($params["status"] == 4): ?>
                <td class="mcenter"><?php echo ($vo["consult_price"]); ?></td><?php endif; ?>
            <td class="mcenter"><?php echo ($vo["bidding_best_price"]); ?></td>
            <td class="mcenter"><?php echo ($vo["reserve_price"]); ?></td>
            <?php if($params["status"] == 4): ?><td  class="mcenter"><?php echo ($vo["channel_from"]); ?></td>
                <?php if($params["auth"] AND $params["status"] == 4): ?><td  class="mcenter"><?php echo ($vo["consult_service"]); ?></td><?php endif; ?>
                <td class="mcenter">
                     <?php echo ($vo["consult_time"]); ?>
                </td><?php endif; ?>
            <?php if($params["auth"] AND $params["status"] > 1 AND $params["status"] != 4): ?><td class="mcenter"><?php echo ($vo["consult_service"]); ?></td><?php endif; ?>
            <?php if($params["status"] == 2): ?><td class="mcenter"><?php echo ($vo["next_trace_time"]); ?></td><?php endif; ?>
            <td class="mcenter">
                <?php if($params["status"] == 1 AND $vo["emp_id"] == 0): ?><a onclick="is_trace_assigned('<?php echo ($vo["id"]); ?>','<?php echo ($vo["consult_status"]); ?>');" href="javascript:;">磋商</a>
                <?php elseif($params["status"] == 2 AND $vo["emp_id"] > 0 AND $vo['emp_id'] == $params['emp_id']): ?>
                    <?php if($params["fenpei_auth"] == true): ?><a href="<?php echo U('Consult/consult_deal',['status'=>$vo[consult_status],'id'=>$vo[id]]);?>">磋商</a>
                        <a href="javascript:;" onclick="fenpei('<?php echo ($vo["id"]); ?>');">分配</a>
                        <?php else: ?>
                        <a href="<?php echo U('Consult/consult_deal',['status'=>$vo[consult_status],'id'=>$vo[id]]);?>">磋商</a><?php endif; ?>
                <?php elseif($params["fenpei_auth"] AND $params["status"] == 2 AND $vo["emp_id"] > 0 AND $vo['emp_id'] != $params['emp_id']): ?>
                    <a href="javascript:;" onclick="fenpei('<?php echo ($vo["id"]); ?>');">分配</a>
                <?php elseif($params["status"] == 3 OR $params["status"] == 4): ?>
                    <a href="<?php echo U('Consult/consult_view',['status'=>$vo[consult_status],'id'=>$vo[id]]);?>" target="_blank">查看</a>
                <?php elseif($params["status"] == 5): ?>
                    <?php if($vo[status] == 12 and ($vo[fail_type] == 2 or $vo[fail_type] == 6) and $vo[car_status] == 8): ?><a href="javascript:;" onclick="re_auction('<?php echo ($vo["order_id"]); ?>','<?php echo ($vo["owner_id"]); ?>')">重拍</a>
                    <?php elseif(($vo[status] == 12) and ($vo[fail_type] == 2 or $vo[fail_type] == 6 )): ?>
                        <a href="javascript:void(0);" style="color:#7f7f7f;">已重拍</a><?php endif; ?>
                    <a href="<?php echo U('Consult/consult_view',['status'=>$vo[consult_status],'id'=>$vo[id]]);?>" target="_blank">查看</a><?php endif; ?>
            </td>
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
    </tbody>
</table>
<div class="error msg" style="color: red; text-align:left;"><?php echo ($errMsg); ?></div>
<div class="pageFaye"><div class="pager"><?php echo ($page); ?></div><div class="clear"></div></div>

<div class="deparHover" style="height: 200px;">
    <h4>分配客服</h4>
    <label>
        <select name="service_id" id="service_id" style="float: right;width: 360px;">
            <option value="0">请选择客服</option>
            <?php foreach($kfs as $kf):?>
            <option value="<?php echo ($kf["emp_id"]); ?>"><?php echo ($kf["real_name"]); ?></option>
            <?php endforeach;?>
        </select>
        分配给：
    </label>
    <div class="deparBtn">
        <input type="button" value="确定" class="deparQue" id="fenpeiQueding">
        <input type="button" value="取消" id="fenpeiQuxiao">
    </div>
</div>

<script type="text/javascript">
    function fenpei(consult_id){
        var bg = $(".yunBei");
        var pp = $(".deparHover");
        var qd = $("#fenpeiQueding");
        var qx = $("#fenpeiQuxiao");

        $("#service_id").select2();
        bg.show();
        pp.show();
        $([bg,qd,qx]).each(function(i,n){
            $(n).unbind('click');
        });
        qx.click(hide_pp);
        bg.click(hide_pp);
        qd.click(function(){
            var service_id = $("#service_id").val();
            $.post("/Consult/assignServer",{"consult_id":consult_id, "service_id":service_id},function(data){
                if(data.code != 200){
                    shibai_alert(data.msg, 1500);
                    return false;
                }
                btn_alert("分配成功",1000,function(){
                    window.location.reload();
                });
            },"json");
        });
        function hide_pp(){
            bg.hide();
            pp.hide();
            bg.unbind('click');
        }
    }
</script>